package com.mew.game.core.common.utils;

import com.mew.common.rest.bo.GameSession;
import com.zebra.common.ZebraBaseMessage;
import com.zebra.remoting.tms.TmsSendMessageUtil;

import java.util.Collection;

public class PushMessageUtil {


    public static void pushMessage(GameSession session, int cmd, ZebraBaseMessage message){
        if(null!=session && !session.isWeakClose()) {
            TmsSendMessageUtil.pushMessage(session.getChannel(), cmd, session.getUserId(), session.getTk(), message);
        }
    }

    public static void broadcastMessage(Collection<GameSession> list, int cmd, ZebraBaseMessage message){
        list.forEach(gs -> pushMessage(gs, cmd, message));
    }
}
